package com.qyhl.webtv.module_news.news.information.program;


import com.qyhl.webtv.commonlib.entity.news.NewsBean;
import com.qyhl.webtv.commonlib.entity.news.SectionBean;

import java.util.List;

/**
 * Created by qyhl on 2017/11/29.
 */

public class ProgramPresenter implements ProgramContract.ProgramPresenter {
    private ProgramModel mModel;
    private ProgramContract.ProgramView mView;

    public ProgramPresenter(ProgramContract.ProgramView mView) {
        this.mView = mView;
        this.mModel = new ProgramModel(this);
    }

    @Override
    public void getSection(String menuId, String type) {
        mModel.getSection(menuId, type);
    }

    @Override
    public void getHotNews(String section) {
        mModel.getHotNews(section);
    }

    @Override
    public void setSection(List<SectionBean> beanList) {
        mView.setSection(beanList);
    }

    @Override
    public void setError(int code, String msg) {
        switch (code) {
            case 0:
                mView.setNetError(msg);
                break;
            case 1:
                mView.setError(msg);
                break;
            case 2:
                mView.setEmpty(msg);
                break;
            default:break;
        }
    }

    @Override
    public void setNews(List<NewsBean> beanList) {
        mView.setNews(beanList);
    }

    @Override
    public void newsError() {
        mView.newsError();
    }
}
